class Director {
    builder: Builder;
    constructor(builder: Builder) {
        this.builder = builder;
    }
    construct(): Product {
        this.builder.buildPartA();
        this.builder.buildPartB();
        return this.builder.getResult();
    }
}

abstract class Builder {
    product: Product;
    protected constructor() {
        this.product = new Product();
    }
    abstract buildPartA(): void;
    abstract buildPartB(): void;
    getResult(): Product {
        return this.product;
    }
}

class ConcreteBuilder extends Builder {
    constructor() {
        super();
    }
    buildPartA() {
        this.product.height = 10;
    }
    buildPartB() {
        this.product.width = 10;
    }
}

class Product {
    height: number = 0;
    width: number = 0;
}

const director = new Director(new ConcreteBuilder());
const product = director.construct();
console.log(product);